找传奇、传世资源到传世资源站!

php 购物车设计源码(含数据库表脚本以及分页)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

有数据操作类以及分页脚本等

<?phprequire( "./mysql.class.php" );class GoodsModel {private $goods_tb_name = 'goods';private $cat_tb_name = 'category';private $gallery_tb_name = 'goods_gallery';public $db;public function __construct ( &$db ) {$this->db = $db;}//添加商品public function add_goods ( $data ) {if ( $this->has_goods( $data['goods_name'], $data['goods_sku'] ) ) {return false;} else {$rs = $this->db->add( $this->goods_tb_name, $data );if ( $rs ) {$insert_id = mysql_insert_id();$data = array('goods_id' => $insert_id,'goods_thumb' => $insert_id . '_1_thumb.jpg','goods_center' => $insert_id . '_2_center.jpg','goods_original' => $insert_id . '_3_original.jpg',);return $this->db->add( $this->gallery_tb_name, $data );} else {return false;}}}//添加商品之前,判断是否存在同样的商品名或者货号public function has_goods ( $goods_name, $goods_sku ) {$sql = "SELECT * FROM {$this->goods_tb_name} WHERE goods_name = '$goods_name' OR goods_sku = '$goods_sku'";$row = $this->db->get_row( $sql );if ( $row ) {return true;} else {return false;}}//取出一条商品所有的信息public function get_goods_detail ( $goods_id ) {return $this->db->get_row( "SELECT * FROM {$this->goods_tb_name} WHERE goods_id = $goods_id" );}//更新商品public function update_goods ( $goods_id, $data ) {return $this->db->update( $this->goods_tb_name, $data, "WHERE goods_id = $goods_id" );}//删除商品public function del_goods ( $goods_id ) {return $this->db->query( "DELETE FROM {$this->goods_tb_name} WHERE goods_id = $goods_id" );}//查找商品public function get_goods_list ( $p = '', $page_size ='' ) {$sql = "SELECT g.*,c.cat_name FROM {$this->goods_tb_name} g LEFT JOIN {$this->cat_tb_name} c ON g.cat_id = c.cat_id";return $this->db->get_all( $sql );}}// $g = new GoodsModel( $db );// // print_r( $g->get_goods_list() );// $data = array( // 'cat_id' => 7,// // 'goods_name' => '荣耀 6 (H60-L01) 3GB内存标准版 白色 移动4G手机',// // 'goods_name' => '华为 畅享5 朦胧灰 全网通版4G手机 双卡双待',// 'goods_name' => '荣耀 6 Plus (PE-TL20) 3GB内存标准版 白色 移动4G手机 双卡双待双通',// 'goods_desc' => '荣耀 6 (H60-L01) 3GB内存标准版 白色 移动4G手机',// 'goods_sku' => 10016,// 'goods_stock' => 100,// 'goods_price' => 2000,// 'is_show' => 1,// );// $res = $g->add_goods( $data );// // $res = $g->update_goods( 16, $data );// // $res = $g->del_goods( 16 );// if ( $res ) {// echo "ok";// } else {// echo "error";// }// print_r( $g->get_goods_detail( 16 ) );?>

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复